Ext.define('Roy.view.base.Grid', {
	extend: 'Ext.grid.Panel',
	
	requires: ['Ext.toolbar.Paging'],
	
//	height : 250,
	//height : 615,
	//自动加载store
	autoLoadStore : undefined,
	//features : [Ext.create('Ext.ux.grid.SelectFeature')], 
	//是否分页
	autoPage : undefined,
//	width:300,
	loadMask : true,
	//加载本地机构的数据 
	initRegion : undefined,
	//是否触发单击表格行的事件
	fireClickRowEvent : true,
	//是否选中表格的第一行
	selectfirst : true,
//	pageSize : Eway.PAGE_SIZE,
	pageSize : 10,
	viewConfig : {
				forceFit : true,
				stripeRows : true
	},
	
	initComponent: function() {
		this.addEvents(
				'select'
			);
		Ext.apply(this, {
//			tbar : [{
//				text : '刷新',
//				handler : this.reload,
//				scope : this
//			}],

//			bbar : new Ext.toolbar.Paging({
//				//原先
//				//pageSize : Eway.PAGE_SIZE,
////				pageSize: (config.pageSize == null || config.pageSize == 'undefiend') ? this.pageSize : config.pageSize ,
////				store:this.config.store,
//				displayInfo:true,
//				displayMsg:'显示第 {0} 到 {1} 条记录，一共 {2} 条',
//				emptyMsg:'没有记录'
//			})
		});
		
		if(this.fireClickRowEvent){
			this.on('rowclick', function(grid, rowIndex){
				var record = grid.getStore().getAt(rowIndex);
				this.fireEvent('select', grid, record);
			}, this);
		}
		else {
		}
		this.on('viewready',function(grid){
			if(this.selectfirst){
//				grid.getSelectionModel().selectRow(0);
			}
		},this);
		if(Ext.SYSTEM_MODE == 'product') {
			if(this.initRegion){
				config.store.setUrlParam("parentId",'0');
			}
			else{
			}
			if(this.autoLoadStore || this.autoLoadStore == undefined){
				if(this.autoPage || this.autoPage == undefined){
					//原先
					//config.store.load({params:{start:0, limit:Eway.PAGE_SIZE}});
					config.store.load({params:{start:0, limit:this.pageSize}});
				}
				else {
					config.store.load();
					this.getBottomToolbar().hide();
				}
			}
			else {
				if(this.autoPage || this.autoPage == undefined){
				}
				else {
					this.getBottomToolbar().hide();
				}
			}
		}
		
		this.callParent(arguments);
	},

	reload : function() {
		this.getStore().reload();
	}
	
});